package pony.myfilters;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

public class MyFilter1 implements Filter {
	FilterConfig filterConfig;
	
	@Override
	public void destroy() {
		// 不做任何事
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
			throws IOException, ServletException {
		HttpServletResponse httpRespsone = (HttpServletResponse)response;
		httpRespsone.setContentType("text/html; charset=UTF-8");
		PrintWriter out = httpRespsone.getWriter();
		out.println("<b><font color=green>filter1</font></b>&nbsp;<br />");
		chain.doFilter(request, response);
	}

	@Override
	public void init(FilterConfig fConfig) throws ServletException {
		this.filterConfig = fConfig;
	}

}
